<% title "Add a new hour" %>

<h2>Add a new hour</h2>
<p>Add new hour for user</p>

<script type="text/javascript" charset="utf-8">
   $(function(){
      var rowData = '<%= render(:partial => "new_hour").gsub(/\n/, "") %>';
      var maxRows = 5; // Number rows to allow at time
      $("#add-new-row").click(function(){
         var length = $("#add-working-hour-rows tr").length;
         if (length == maxRows) {
            alert(maxRows + " rows are allowed at a time");
            return false;
         }
         $("#add-working-hour-rows").append(rowData);
         return false;
      });
   });
</script>

<% form_for :hour, :url => user_working_hours_path(@user), :html => { :id => 'add-working-hours' } do |f| %>
<div id="add-hours">
	<table id="add-working-hour-rows" class="hours-expenses-table">
		<%= render :partial => 'new_hour' %>
	</table>
	<a href="#" id="add-new-row">Add a new row</a>
</div>

<br />

<%= submit_tag 'Save' %> or <%= link_to('Back', user_working_hours_path(@user)) %>
<% end %>


